 package com.example.isoftservice.controller;


import com.example.isoftservice.pojos.Order;
import com.example.isoftservice.service.OrderService;
import com.example.isoftservice.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@CrossOrigin
@RestController
public class OrderController {
    @Resource
    private OrderService orderService;

    @RequestMapping(value = "/order/select", method = RequestMethod.GET)

    public Result<Map<String, Object>> orderselect(Order order) {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.orderSelect(order));


        return result;

    }


    @RequestMapping(value = "/order/product", method = RequestMethod.GET)

    public Result<Map<String, Object>> product() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.selectProduct());


        return result;

    }

    @RequestMapping(value = "/order/user", method = RequestMethod.GET)

    public Result<Map<String, Object>> user() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.selectUser());


        return result;

    }

    @RequestMapping(value = "/order/storeid", method = RequestMethod.GET)

    public Result<Map<String, Object>> storeid() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.selectStoreId());


        return result;

    }

    @RequestMapping(value = "/order/insert", method = RequestMethod.POST)

    public Result<Map<String, Object>> insert(@RequestBody Order order) {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.orderInsert(order));


        return result;

    }
    @RequestMapping(value = "/order/update",method = RequestMethod.POST)
    public Map<String, Object> orderUpdate(@RequestBody Order order) {
        return this.orderService.orderUpdate(order);
    }

    @RequestMapping(value = "/order/delete",method = RequestMethod.POST)
    public Map<String, Object> orderDelete(@RequestBody Order order) {
        return this.orderService.orderDelete(order);
    }


    @RequestMapping(value = "/order/completenumber", method = RequestMethod.GET)

    public Result<Map<String, Object>> completenumber() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.orderCompleteNumber());


        return result;

    }

    @RequestMapping(value = "/order/nocompletenumber", method = RequestMethod.GET)

    public Result<Map<String, Object>> nocompletenumber() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.orderNoCompleteNumber());


        return result;

    }

    @RequestMapping(value = "/order/number", method = RequestMethod.GET)

    public Result<Map<String, Object>> ordernumber() {
        Result<Map<String, Object>> result = new Result<>();
        result.setMessage("查询成功");
        result.setCode(0);
        result.setSuccess(true);
        result.setResult(orderService.orderNumber());


        return result;

    }
}


//
//    @RequestMapping(value = "/stock/delete", method = RequestMethod.POST)
//
//    public Result<Map<String, Object>> Delete(@RequestBody Stock stock) {
//
//        Result<Map<String, Object>> result = new Result<>();
//        result.setMessage("成功");
//        result.setCode(0);
//        result.setSuccess(true);
//        result.setResult(stockService.stockDelete(stock));
//
//
//        return result;
//
//    }
//
//    @RequestMapping(value = "/stock/update", method = RequestMethod.GET)
//    public Result<Map<String, Object>> modifyStockInfo(Stock stock) {
//        Result<Map<String, Object>> result = new Result<>();
//        result.setMessage("成功");
//        result.setCode(0);
//        result.setSuccess(true);
//        result.setResult(stockService.stockUpdate(stock));
//        return result;
//
//
//    }
//}
